The TreeView control is used to display a hierarchy of nodes. You can expand and
collapse these nodes by clicking them.Drag and drop TreeView control from
toolbox on the window Form.
Code:
private void frmTreeView_Load(object sender, EventArgs e)
{
treeView1.Nodes.Add("");
treeView1.Nodes[0].Text= "Database";// this isparent node
// fallowing are the child node of 'Database'
treeView1.Nodes[0].Nodes.Add("sql server");
treeView1.Nodes[0].Nodes.Add("my sql");
treeView1.Nodes.Add("");
treeView1.Nodes[1].Text = "Programming Language";// this is parent node
// fallowing are the child node of 'Programming Language'
treeView1.Nodes[1].Nodes.Add("C#");
treeView1.Nodes[1].Nodes.Add("J#");
treeView1.Nodes[1].Nodes.Add("java");
}
Run the project
When you expand the Database node then child node of database will show .
TreeView Properties
ShowRootLine: set the ShowRootLine to show or hide Line, by default it is true.
ForeColor: ForeColor of TreeView can be changed through TreeView ForeColor property.
Example:
private void frmTreeView_Load(object sender, EventArgs e)
{
//change forecolor of treeview
treeView1.ForeColor= Color.Red;
}
BackColor: BackColor of TreeView can be changed through TreeView BackColor property.
Example:
privatevoid frmTreeView_Load(object sender, EventArgs e)
{
//Change BackColor of TreeView
treeView1.BackColor = Color.CadetBlue;
}
Anonymous User
12-Jan-2013Could you please elaborate your problem?
Manmohan Jha
12-Jan-2013Thx & regard
Manmohan Jha
John Smith
10-Jan-2013http://www.mindstick.com/Articles/022711d0-b15d-4dc0-b50b-e1a9b4cb6a82/?How%20to%20use%20Tree%20View%20Control%20in%20C
http://www.mindstick.com/Articles/4d20f28e-c5ae-4245-affc-59a68c23c198/?Node%20Insertion%20in%20TreeView%20control%20in%20C
http://www.mindstick.com/Articles/ac6a8a90-4435-4d03-84b5-0c0cebe402b4/?Drag-Drop%20in%20TreeView%20in%20C
Manmohan Jha
10-Jan-2013Ex...
how do that?
Thx & regard
Manmohan Jha
manmohan_jh@sify.com